<?php
	defined('RUN') or die('No access');

	class SettingController
	{
		public function index()
		{
			$data = Model::get('admin')->getLayoutData();
			
			if (Input::post('action') == 'update' && Security::checkToken('setting_form', Input::post('token')))
			{
				$settings = array(
						'page_name' => strip_tags(Input::post('page_name')),
						'page_description' => strip_tags(Input::post('page_description')),
						'page_keywords' => strip_tags(Input::post('page_keywords'))
					);

				Model::get('setting')->update(
					$settings['page_name'],
					$settings['page_description'],
					$settings['page_keywords']
					);
			}
			
			$data['setting'] = Model::get('setting')->getAll();
			$data['content_file'] = 'setting/index.tpl';
			View::load('layout.tpl', $data, 'admin');
		}
	}
